#
# @name 框架实例.py
# @desc 监听者模式
# @author moyueheng
# @time 2021年03月03日 21:41:31 星期三
#
from abc import ABCMeta, abstractmethod


class Observable:
    """被观察者基类"""

    def __init__(self):
        self.__observers = []

    def addObserver(self, observer):
        self.__observers.append(observer)
        pass

    def removeObserver(self, observer):
        self.__observers.remove(observer)

    def notifyObservers(self, object = 0):
        """通知观察者"""
        for o in self.__observers:
            o.update(self, object)

class Observer(metaclass=ABCMeta):
    """观察者模式基类"""

    @abstractmethod
    def update(self, observable, object):
        pass






def main():
    pass



if __name__ == "__main__":
    main()